{% extends "base.html" %}

{% block content %}
<div class="container mt-4">
    <h2>欢迎, {{ customer.customerName }}</h2>

    <!-- 银行卡列表 -->
    <div class="card mt-4">
        <div class="card-header">
            <h4>我的银行卡</h4>
        </div>
        <div class="card-body">
            <div class="row">
                {% for card in cards %}
                <div class="col-md-4 mb-3">
                    <div class="card">
                        <div class="card-body">
                            <h5 class="card-title">{{ card.savingName }}卡</h5>
                            <p class="card-text">卡号: {{ card.cardID }}</p>
                            <p class="card-text">余额: ¥{{ "%.2f"|format(card.balance) }}</p>
                            <p class="card-text">
                                状态:
                                {% if card.IsReportLoss == '是' or card.IsReportLoss == 1 or card.IsReportLoss == True %}
                                    <span class="badge bg-danger">已挂失</span>
                                {% else %}
                                    <span class="badge bg-success">正常</span>
                                {% endif %}
                            </p>
                        </div>
                    </div>
                </div>
                {% endfor %}
            </div>
        </div>
    </div>

    <!-- 交易记录 -->
    <div class="card mt-4">
        <div class="card-header">
            <h4>最近交易</h4>
        </div>
        <div class="card-body">
            <table class="table">
                <thead>
                    <tr>
                        <th>日期</th>
                        <th>类型</th>
                        <th>金额</th>
                        <th>备注</th>
                    </tr>
                </thead>
                <tbody>
                    {% for trans in transactions %}
                    <tr>
                        <td>{{ trans.tradeDate.strftime('%Y-%m-%d %H:%M') }}</td>
                        <td>{{ trans.tradeType }}</td>
                        <td class="{{ 'text-success' if trans.tradeType == '存款' or trans.tradeType == '转账收入' else 'text-danger' }}">
                            ¥{{ "%.2f"|format(trans.tradeMoney) }}
                        </td>
                        <td>{{ trans.remark }}</td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
</div>
{% endblock %}